<template>
  <el-main>
    <!--<el-form :inline="true" class="demo-form-inline">
      <el-form-item label="合同名称">
        <el-input v-model="queryForm.name" placeholder="合同名称" clear></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="query">查询</el-button>
      </el-form-item>
    </el-form>-->
    <el-table
        :data="tableData"
        style="width: 100%"
        :row-class-name="tableRowClassName">
      <el-table-column
          prop="taskId"
          label="任务Id"
          width="150">
      </el-table-column>
      <el-table-column
          prop="taskName"
          label="任务名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="name"
          label="合同名称"
          width="180">
      </el-table-column>
      <el-table-column
          prop="date"
          label="合同日期"
          width="180">
      </el-table-column>
      <el-table-column
          prop="total"
          label="合同金额">
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
              size="mini"
              @click="checkDialog(scope.$index, scope.row)">审核</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--审核对话框-->
    <el-dialog
        title="审核"
        :visible.sync="dialogVisible"
        width="50%">
      <span>
          <el-form :model="checkForm" ref="numberValidateForm" label-width="100px" class="demo-ruleForm">
            <el-form-item label="审核意见" prop="age">
              <el-input v-model.number="checkForm.age"></el-input>
            </el-form-item>
            <el-form-item label="是否通过" prop="age">
              <el-switch v-model="checkForm.delivery"></el-switch>
            </el-form-item>
          </el-form>
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="check">确 定</el-button>
      </span>
    </el-dialog>



  </el-main>
</template>

<script>
export default {
  name: "HeTong",
  data() {
    return {
      tableData: [],
      queryForm:{
        size: 2
      },
      page: 1,
      dialogVisible: false,
      checkForm:{

      }
    }
  },
  methods: {
    tableRowClassName({row, rowIndex}) {
      if (rowIndex === 1) {
        return 'warning-row';
      } else if (rowIndex === 3) {
        return 'success-row';
      }
      return '';
    },
    checkDialog(index,row) {
      this.dialogVisible = true;
      this.checkForm.taskId = row.taskId;
    },
    check() {
      this.axios.get('hetong/activiti/complete', {params: this.checkForm}).then(res => {
        this.$message.success("审核通过");
        this.pageQuery();
      })
    },
    pageQuery() {
      this.axios.get('hetong/activiti/myTask').then(res => {
        this.tableData = res.data.data;
      });
    }
  },
  mounted() {
    this.pageQuery();
  }
}
</script>

<style scoped>
.el-row {
  margin-top: 20px;
}
.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>